package process0.gui;

import java.io.File;

import java.io.FileNotFoundException;
import java.util.Scanner;

import org.antlr.runtime.RecognitionException;

public class MainGui {
	public static void main(String[] args) {
		String content = null;

		if (args.length == 2) {
			if (args[0].equals("-img")) {
				try {
					content = new Scanner(new File(args[1])).useDelimiter("\\Z")
							.next();
					// content = new Scanner(new
					// File("program.cess")).useDelimiter("\\Z")
					// .next();
					InputDev inputDev = new Interpreter();
					try {
						inputDev.showWorkflow(content);
					} catch (RecognitionException e) {
						System.out.println("usege\n -cons <feliname.cess>\n -img <feliname.cess>\n <feliname.cess>");
					}
				} catch (FileNotFoundException e1) {
					System.out.println("usege\n -cons <feliname.cess>\n -img <feliname.cess>\n <feliname.cess>");

				}


			} else if (args[0].equals("-conf")) {
				try {
					content = new Scanner(new File(args[1])).useDelimiter("\\Z")
							.next();
					// content = new Scanner(new
					// File("program.cess")).useDelimiter("\\Z")
					// .next();
					InputDev inputDev = new Interpreter();
					try {
						inputDev.translate(content);
					} catch (RecognitionException e) {
						e.printStackTrace();
					}
				} catch (FileNotFoundException e1) {
					System.out.println("usege\n -cons <feliname.cess>\n -img <feliname.cess>\n <feliname.cess>");
				}


			}

		} else if (args.length == 1) {
			try {
				content = new Scanner(new File(args[0])).useDelimiter("\\Z")
						.next();
				// content = new Scanner(new
				// File("program.cess")).useDelimiter("\\Z")
				// .next();
				InputDev inputDev = new Interpreter();
				try {
					inputDev.translate(content);
					inputDev.showWorkflow(content);
				} catch (RecognitionException e) {
					e.printStackTrace();
				}
			} catch (FileNotFoundException e1) {
				System.out.println("usege\n -cons <feliname.cess>\n -img <feliname.cess>\n <feliname.cess>");
			}

			
		} else {
			System.out.println("usege\n -cons <feliname.cess>\n -img <feliname.cess>\n <feliname.cess>");
		}

	}
}
